<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="交易流水号" prop="orderNo">
        <el-input
          v-model="queryParams.orderNo"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="业务订单号" prop="businessOrderPlanNo">
        <el-input
          v-model="queryParams.businessOrderPlanNo"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="交易账户" prop="tradeAccount">
        <el-input
          v-model="queryParams.tradeAccount"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="交易账号" prop="tradeAccountNo">
        <el-input
          v-model="queryParams.tradeAccountNo"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="交易账户类型" prop="tradeAccountType">
        <el-input
          v-model="queryParams.tradeAccountType"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="用户类型" prop="userType">
        <el-input
          v-model="queryParams.userType"
          placeholder="用户类型"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="支付方式" prop="payWay">
        <el-input
          v-model="queryParams.payWay"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="结算金额" prop="finalAmount">
        <el-input
          v-model="queryParams.finalAmount"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="交易对手" prop="tradeUser">
        <el-input
          v-model="queryParams.tradeUser"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="对手账号" prop="dsAccount">
        <el-input
          v-model="queryParams.dsAccount"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="交易渠道" prop="tradeQudao">
        <el-input
          v-model="queryParams.tradeQudao"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="渠道订单号" prop="qudaoOrderNo">
        <el-input
          v-model="queryParams.qudaoOrderNo"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="交易结果" prop="tradeResult">
        <el-input
          v-model="queryParams.tradeResult"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="订单金额" prop="amount">
        <el-input
          v-model="queryParams.amount"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="支付金额" prop="payAmount">
        <el-input
          v-model="queryParams.payAmount"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>


      <el-form-item label="发起交易日期" prop="tradeDateFqStart">
        <el-date-picker clearable
                        v-model="queryParams.tradeDateFqStart"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择发起交易日期">
        </el-date-picker>
      </el-form-item>

      <el-form-item label="发起交易日期" prop="tradeDateFqEnd">
        <el-date-picker clearable
                        v-model="queryParams.tradeDateFqEnd"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择发起交易日期">
        </el-date-picker>
      </el-form-item>


      <el-form-item label="支付截止日期" prop="tradeDateJzStart">
        <el-date-picker clearable
                        v-model="queryParams.tradeDateJzStart"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择支付截止日期">
        </el-date-picker>
      </el-form-item>

      <el-form-item label="支付截止日期" prop="tradeDateJzEnd">
        <el-date-picker clearable
                        v-model="queryParams.tradeDateJzEnd"
                        type="date"
                        value-format="yyyy-MM-dd"
                        placeholder="请选择支付截止日期">
        </el-date-picker>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>

    </el-form>


    <el-table v-loading="loading" :data="dealList" @selection-change="handleSelectionChange">

      <el-table-column label="交易流水号" align="center" prop="orderNo" />

      <el-table-column label="业务订单号" align="center" prop="orderNo" />
      <el-table-column label="交易账户类型" align="center" prop="tradeAccountType" />
      <el-table-column label="用户类型" align="center" prop="tradeAccountNo" />
      <el-table-column label="交易账号" align="center" prop="dsAccount" />
      <el-table-column label="交易账户" align="center" prop="tradeAccountNo" />
      <el-table-column label="支付方式" align="center" prop="payWay" />
      <el-table-column label="结算金额" align="center" prop="finalAmount" />
      <el-table-column label="交易对手" align="center" prop="tradeUser" />
      <el-table-column label="对手账号" align="center" prop="dsAccount" />
      <el-table-column label="交易渠道" align="center" prop="tradeQudao" />
      <el-table-column label="渠道订单号" align="center" prop="qudaoOrderNo" />
      <el-table-column label="交易结果" align="center" prop="tradeResult" />
      <el-table-column label="返回码" align="center" prop="returnCode" />
      <el-table-column label="返回信息" align="center" prop="returnMsg" />
      <el-table-column label="发起交易日期" align="center" prop="tradeDateFq" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.tradeDateFq, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="执行交易日期" align="center" prop="tradeDateZx" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.tradeDateZx, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="支付截止日期" align="center" prop="tradeDateJz" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.tradeDateJz, '{y}-{m}-{d}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="费率" align="center" prop="tradeRate" />
      <el-table-column label="手续费" align="center" prop="commissionFee" />
      <el-table-column label="订单金额" align="center" prop="amount" />
      <el-table-column label="支付金额" align="center" prop="payAmount" />


      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

  </div>
</template>

<script>
import { listDeal, getDeal, delDeal, addDeal, updateDeal } from "@/api/deals/deal";

export default {
  name: "Deal",
  data() {
    return {
      // 总条数
      total: 0,
      // 交易流水（支付流水信息）表格数据
      dealList: [],
      // 显示搜索条件
      showSearch: true,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        orderNo: null,
        tradeAccount: null,
        businessOrderPlanNo:null,
        tradeAccountType: null,
        tradeAccountNo: null,
        userType: null,
        payWay: null,
        amount: null,
        payAmount: null,
        finalAmount: null,
        tradeUser: null,
        dsAccount: null,
        tradeQudao: null,
        qudaoOrderNo: null,
        tradeDateFqStart: null,
        tradeDateFqEnd: null,
        tradeDateJzStart: null,
        tradeDateJzEnd: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {}
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询交易流水（支付流水信息）列表 */
    getList() {
      listDeal(this.queryParams).then(response => {
        this.dealList = response.rows;
        this.total = response.total;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        orderNo: null,
        tradeAccount: null,
        businessOrderPlanNo:null,
        tradeAccountType: null,
        tradeAccountNo: null,
        userType: null,
        payWay: null,
        amount: null,
        payAmount: null,
        finalAmount: null,
        tradeUser: null,
        dsAccount: null,
        tradeQudao: null,
        qudaoOrderNo: null,
        tradeDateFqStart: null,
        tradeDateFqEnd: null,
        tradeDateJzStart: null,
        tradeDateJzEnd: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
  }
};
</script>
